<!DOCTYPE html>
<html>

<head>
    <#include "/yq/admin/components/meta.html" />
    <title>蓁奕科技 ${metaTitleSuffix!}</title>
    <#include "/yq/admin/components/stylesheets.html" />
</head>

<body>
    <div id='app'>
        <el-container>
            <#assign menuIndex="1-3" />
            <#include "/yq/admin/components/menu.html" />
            <el-container>
                <#include "/yq/admin/components/header.html" />
                <el-main>
                    <template>
                        <el-button @click='onAdd'>新增</el-button>
                        <el-table :data="items" style="width: 100%">
                            <!-- <el-table-column prop="id" label="id">
                            </el-table-column> -->
                            <el-table-column prop="title" label="标题">
                            </el-table-column>
                            <el-table-column prop="status" label="状态">
                                <template slot-scope="scope">
                                    <span v-if='scope.row.status == 1'>正常</span>
                                    <span v-if='scope.row.status == 0'>禁用</span>
                                </template>
                            </el-table-column>
                            <el-table-column prop="sort" label="排序">
                            </el-table-column>
                            <el-table-column  label="操作">
                                <template slot-scope="scope">
                                    <el-button type="text" @click="onEdit(scope.row)">查看</el-button>
                                    <el-button type="text" @click="setTop(scope.row, 1)" v-if="scope.row.isTop === 0">设置置顶</el-button>
                                    <el-button type="text" @click="setTop(scope.row, 0)" v-else-if="scope.row.isTop === 1">取消置顶</el-button>
                                    <el-button type="text" @click="onDelte(scope.row)" style="color: red;">删除</el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                        <#include '/components/page.html' />
                    </template>
                </el-main>
            </el-container>
        </el-container>
        <#include "/yq/admin/components/footer.html" />
    </div>
    <#include "/yq/admin/components/scripts.html" />
    <script type="text/javascript">
    var vue = new Vue({
        el: '#app',
        data() {
            return {
                items: ${items!'[]'}
            }
        },
        mounted: function() {},
        methods: {
            onAdd(){
                location.href = '/yq/admin/category/info'
            },
            onEdit(info) {
                window.location.href = '/yq/admin/category/info?id=' + info.id;
            },
            onDelte(info) {
                this.$confirm('确定删除?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    var param = {
                        id: info.id
                    }
                    axiosRequest(param, '/yq/admin/category/delete', '')
                }).catch(() => {});
            },
            setTop(info, val) {
                var params = {
                    id: info.id,
                    isTop: val
                }
                var success = res => {
                    this.$message({
                        message: '设置成功',
                        type: 'success'
                    });
                    window.location.reload();
                }
                var fail = res => {
                    this.$message.error('设置失败');
                }
                var comp = () => {}
                axiosRequestPro(params, '/yq/admin/category/updateIsTop', success, fail, comp);
            }
        },
        filters: {
            fmt(date) {
                return date
            }
        }
    })
    </script>
</body>

</html>